

    function updateChat() {    
	    var url = "/getchats";
	    url += "?table=" + window.table_number;
		//downloadUrl(url, "GET", null, onChatsReturned);
	}
	
	function sendChat() {
	    var url = "/getchats"
	    url += "?table=" + table_number;
		downloadUrl(url, "POST", "content=" + encodeURI(document.getElementById("chattext").value), onChatsReturned);
		document.getElementById("chattext").value = "";
	}

	function onChatsReturned(responseText) {
		document.getElementById("chats").innerHTML = responseText;
		scrollToBottom();
	}

	function setupChat(table_number) {
	    window.table_number = (table_number)?table_number: "0";
 		window.setInterval("updateChat()", 20000);
		updateChat(table_number);
	}
	
	function scrollToBottom() {
	  var chatDiv = document.getElementById("chats");
	  chatDiv.scrollTop = chatDiv.scrollHeight;
	}
